//Will Zepeda
//GSP-362
//Material.cpp
#include "Material.h"
#include "ENUM.h"
#include "DirectX.h"
//#include "DX include.h"

Material::Material()
{
	//zero out material struct
	ZeroMemory(&mMaterial, sizeof(mMaterial)); 

	//init material
	//init material to white
	mMaterial.Ambient  = D3DXCOLOR(0.5f, 0.5f, 0.5f, 1.0f);
	mMaterial.Diffuse  = D3DXCOLOR(1.0f, 1.0f, 1.0f, 1.0f);
	mMaterial.Specular = D3DXCOLOR(0.5f, 0.5f, 0.5f, 1.0f);
	mMaterial.Power = 10.0f;
	//DirectXFramework::Instance()->getDevice()->SetMaterial(&mMaterial);

	theta = 0.0f;
	matState = 0;
}
Material::~Material()
{

}
void Material::setToRed()
{
	mMaterial.Ambient  = D3DXCOLOR(0.5f, 0.0f, 0.0f, 1.0f);
	mMaterial.Diffuse  = D3DXCOLOR(0.5f, 0.0f, 0.0f, 1.0f);
	mMaterial.Specular = D3DXCOLOR(0.8f, 0.8f, 0.8f, 1.0f);
	//DirectXFramework::Instance()->getDevice()->SetMaterial(&mMaterial);
}
void Material::setToGreen()
{
	mMaterial.Ambient  = D3DXCOLOR(0.0f, 0.5f, 0.0f, 1.0f);
	mMaterial.Diffuse  = D3DXCOLOR(0.0f, 0.5f, 0.0f, 1.0f);
	mMaterial.Specular = D3DXCOLOR(0.8f, 0.8f, 0.8f, 1.0f);
	//DirectXFramework::Instance()->getDevice()->SetMaterial(&mMaterial);
}
void Material::setToWhite()
{
	mMaterial.Ambient  = D3DXCOLOR(0.5f, 0.5f, 0.5f, 1.0f);
	mMaterial.Diffuse  = D3DXCOLOR(1.0f, 1.0f, 1.0f, 1.0f);
	mMaterial.Specular = D3DXCOLOR(0.8f, 0.8f, 0.8f, 1.0f);
	//DirectXFramework::Instance()->getDevice()->SetMaterial(&mMaterial);
}
void Material::setToYellow()
{
	mMaterial.Ambient  = D3DXCOLOR(1.0f, 1.0f, 0.0f, 1.0f);
	mMaterial.Diffuse  = D3DXCOLOR(1.0f, 1.0f, 0.0f, 1.0f);
	mMaterial.Specular = D3DXCOLOR(0.8f, 0.8f, 0.8f, 1.0f);
	//DirectXFramework::Instance()->getDevice()->SetMaterial(&mMaterial);
}
void Material::changeCrazyColors()
{
	switch(matState)
	{
	case ADD: 
		{
			theta+=1.0f;
			if(theta > 360.0f)
				matState = SUB;
		}
		break;
	case SUB: 
		{
			theta-=1.0f;
			if(theta < 0.0f)
				matState = ADD;
		}
		break;
	}
}
void Material::setCrazyMat()
{
	float r = ((sin(D3DXToRadian(theta))+1.0f)/2.0f);
	float g = ((sin(D3DXToRadian(2*theta))+1.0f)/2.0f);
	float b = ((sin(D3DXToRadian(theta/2))+1.0f)/2.0f);

	mMaterial.Ambient = D3DXCOLOR(r, g, b, 1.0f);
	mMaterial.Diffuse  = D3DXCOLOR(r, g, b, 1.0f);
	mMaterial.Specular = D3DXCOLOR(0.8f, 0.8f, 0.8f, 1.0f);
}
void Material::setPower(float aPower)
{
	mMaterial.Power = aPower;
}